using System.Collections.Generic;
using Tools.Domain.Specifications;
using Webshop20.Domain.Catalog.Core.Products.Filter.InputContracts;
using Webshop20.Domain.Catalog.Specifications;
using Webshop20.Domain.Shared.Products.Core;

namespace Webshop20.Domain.Catalog.Core.Products.Filter.Implementations
{
    public class ProductsByMaximumPriceSpecificationFilter : ISpecificationFilter<Product>
    {
        public void AddSpecificationTo<S>(ref IList<ISpecification<Product>> specifications, S data)
        {
            var maximumPrice = data as IMaximumPrice;
            if (maximumPrice.MaximumPriceValue != null)
                specifications.Add(new MaximumPriceSpecification(maximumPrice.MaximumPriceValue));
        }
    }
}